import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";

/**
 * index.js
 * @date 2018/9/30
 */
import React from 'react';
import Preview from "./Preview";

var PagePreview = /*#__PURE__*/function (_React$Component) {
  _inherits(PagePreview, _React$Component);

  var _super = _createSuper(PagePreview);

  function PagePreview(props) {
    var _this;

    _classCallCheck(this, PagePreview);

    _this = _super.call(this, props);
    _this.ref = {};
    _this.state = {
      pageCode: ''
    };
    _this.handleRefresh = _this.handleRefresh.bind(_assertThisInitialized(_this));
    _this.state = {
      pageCode: _this.getPageCode()
    };
    return _this;
  }

  _createClass(PagePreview, [{
    key: "render",
    value: function render() {
      var pageCode = this.state.pageCode;
      return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Preview, {
        pageCode: pageCode,
        onRefresh: this.handleRefresh
      }));
    }
  }, {
    key: "getPageCode",
    value: function getPageCode() {
      var pageCode = this.props.match.params.pageCode;
      return pageCode;
    }
    /**
     * reset pageCode from router
     */

  }, {
    key: "handleRefresh",
    value: function handleRefresh() {
      this.setState({
        pageCode: this.getPageCode()
      });
    }
  }]);

  return PagePreview;
}(React.Component);

export { PagePreview as default };